package portal;

import javax.portlet.GenericPortlet;
import javax.portlet.ActionRequest;
import javax.portlet.RenderRequest;
import javax.portlet.ActionResponse;
import javax.portlet.RenderResponse;
import javax.portlet.PortletException;
import java.io.IOException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.PortletSession;

/**
 * UploadWorkflow Portlet Class
 */
public class ResultsViewerPortlet extends GenericPortlet {

    public void processAction(ActionRequest request, ActionResponse response) throws PortletException, IOException {
    }

    public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {

        PortletSession session = request.getPortletSession();
        String jobID = request.getParameter("job");
        if (jobID == null) {

            response.setContentType("text/html");
            PortletRequestDispatcher dispatcher =
                    getPortletContext().getRequestDispatcher("/WEB-INF/jsp/jobSelector.jsp");
            dispatcher.include(request, response);
        } else {

            session.setAttribute("job", jobID);
            System.out.println(jobID);
            PortletRequestDispatcher dispatcher =
                    getPortletContext().getRequestDispatcher("/WEB-INF/jsp/results.jsp");
            dispatcher.include(request, response);
        }
    }
}
